package com.sunyard.manage.controller;

import com.sunyard.dal.bo.dashboard.MapDataBO;
import com.sunyard.dal.dto.MapDataDTO;
import com.sunyard.dal.dto.SignNumberResDTO;
import com.sunyard.manage.service.HomepageDisplayService;
import com.sunyard.utils.Response.BaseResult;
import com.sunyard.utils.Response.GetResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(tags = "OperatorAuditController", description = "首页控制层")
@Slf4j
@RestController
@RequestMapping(value = "/homepageDisplay")
public class HomepageDisplayController {

    @Autowired
    HomepageDisplayService homepageDisplayService;

    /**
     * @Description: 查询待审核人员数量
     * @Author: chengy.wei
     * @Date: 2022/07/12 21:37
     */
    @ApiOperation("获取首页参数")
    @RequestMapping(value = "/getCount")
    @ResponseBody
    public BaseResult getCount(HttpServletRequest request) throws Exception {
        try {
            return homepageDisplayService.getCount(request);
        } catch (Exception e) {
            e.printStackTrace();
            return GetResult.getResultErr();
        }
    }

    /**
     * @Description: 获取所有省的数据
     * @Author: chengy.wei
     * @Date: 2022/07/12 21:37
     */
    @ApiOperation("获取所有省的数据")
    @RequestMapping(value = "/getMapData")
    @ResponseBody
    public BaseResult<List<MapDataDTO>> getMapData(HttpServletRequest request) throws Exception {
        return GetResult.getResult(homepageDisplayService.getMapData(request));
    }

    /**
     * @Description: 获取所有省下面的数据
     * @Author: chengy.wei
     * @Date: 2022/07/12 21:37
     */
    @ApiOperation("获取所有省下面的数据")
    @RequestMapping(value = "/getMapDataByProCode")
    @ResponseBody
    public BaseResult<List<MapDataDTO>> getMapDataByProCode(@RequestBody MapDataBO mapDataBO, HttpServletRequest request) throws Exception {
        return GetResult.getResult(homepageDisplayService.getMapDataByProCode(mapDataBO, request));
    }

    /**
     * @Description: 获取所有市下面的数据
     * @Author: chengy.wei
     * @Date: 2022/07/12 21:37
     */
    @ApiOperation("获取所有市下面的数据")
    @RequestMapping(value = "/getMapDataByCtCode")
    @ResponseBody
    public BaseResult<List<MapDataDTO>> getMapDataByCtCode(@RequestBody MapDataBO mapDataBO, HttpServletRequest request) throws Exception {
        return GetResult.getResult(homepageDisplayService.getMapDataByCtCode(mapDataBO, request));
    }

    /**
     * @Description: 获取常用功能
     * @Author: chengy.wei
     * @Date: 2022/07/12 21:37
     */
    @ApiOperation("获取常用功能")
    @RequestMapping(value = "/getPopedomByOpId")
    @ResponseBody
    public BaseResult<List<String>> getPopedomByOpId(HttpServletRequest request) throws Exception {
        return GetResult.getResult(homepageDisplayService.getPopedomByOpId(request));
    }

    /**
     * @Description: 获取常用功能
     * @Author: chengy.wei
     * @Date: 2022/07/12 21:37
     */
    @ApiOperation("获取当前机构未签到钥匙数量")
    @RequestMapping(value = "/getUnSignNumber")
    @ResponseBody
    public BaseResult<SignNumberResDTO> getUnSignNumber(HttpServletRequest request) {
        return homepageDisplayService.getUnSignNumber(request);
    }
}
